<?php

namespace app\admin\model;

use think\Model;

class Brewconsumption extends Model
{
    // 表名
    protected $table = 'brewconsumption';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'material_type_text'
    ];
    

    
    public function getMaterialTypeList()
    {
        return ['malt' => __('Material_type malt'),'hops' => __('Material_type hops'),'yeast' => __('Material_type yeast')];
    }     


    public function getMaterialTypeTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['material_type']) ? $data['material_type'] : '');
        $list = $this->getMaterialTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
